package com.vim.common.utils;

import com.vim.common.exception.BusinessException;
import com.vim.modules.mall.model.base.MallResponseEntity;

/**
 * @作者 Administrator
 * @时间 2020-10-04 11:30
 * @版本 1.0
 */
public class AssertUtils {

    /**
     * 判断非空
     */
    public static void assertAjaxOK(MallResponseEntity entity){
        if(null == entity || entity.getCode() != 200){
            throw new BusinessException("获取数据失败!");
        }
    }

    /**
     * 判断非空
     */
    public static void assertNotNull(Object source, String message){
        if(null == source){
            throw new BusinessException(message);
        }
    }

    /**
     * 条件满足
     */
    public static void assertTrue(boolean flag, String message){
        if(!flag){
            throw new BusinessException(message);
        }
    }

    /**
     * 条件不满足
     */
    public static void assertFalse(boolean flag, String message){
        if(flag){
            throw new BusinessException(message);
        }
    }
}
